package com.ftg.learn.util;

import lombok.Data;

import java.util.Collections;

/**
 * @Author: huye
 * @Description: TODO
 * @DateTime: 2022/3/14 8:42
 **/
@Data
public class ResEntity {

    private int code;

    private String msg;

    private Object data;

    public ResEntity(){

    }

    public ResEntity(int code,String msg,Object data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResEntity OK(String msg, Object data){
        return new ResEntity(0,msg,data);
    }

    public ResEntity OK(){
        return new ResEntity(0,msg, Collections.emptyMap());
    }

    public ResEntity OK(Object data){
        return new ResEntity(0,"success",data);
    }

    public ResEntity FAILURE(String msg){
        return new ResEntity(-1,msg,Collections.emptyMap());
    }

    public ResEntity FAILURE(){
        return new ResEntity(-1,"failure", Collections.emptyMap());
    }

}


